<br/>
<div id="user_info">
  
  <table class="listing">
    <tr>
      <th><strong><%= @user.chinese_name %></strong></th>
      
    </tr>
    <tr class="even">
      
      <td>剩余积分:<%= @user.remaining %> 
        <hr/>
      </td>
    </tr>
  </table>
  <br/>

<% form_for :productuser,@productuser,:url => productusers_path do |f| -%>
  <p/>
  <%= hidden_field_tag "productuser[user_id]",params[:id] %>
  产品: <%#= f.text_field :product_id %> <%#= collection_select :productuser,:product_id,Product.find(:all),:id,:name_with_remaining,{:prompt => true} %>
   <select name="productuser[product_id]" id="productuser_product_id">
   <OPTION value="0">请选择产品</OPTION>
    <%= option_groups_from_collection_for_select(@categories, :products, :name, :id, :name_with_remaining,0) %>
    </select>
   
    单价: <%= f.text_field :per_cost,:size =>5 ,:readonly=>true,:style=>"cursor: text;" %>
    <%#= render :partial => 'product_cost_info',:locals =>{:f => f} %>

   数量:<%= f.text_field :amount ,:size =>5 ,:onchange => "$('productuser_total_cost').value=$('productuser_per_cost').value * $('productuser_amount').value;
  " %>
   总价:<%= f.text_field :total_cost,:size =>5 ,:readonly=>true,:onclick => "$('productuser_total_cost').value=$('productuser_per_cost').value * $('productuser_amount').value;" %>
<p/>
  领取时间:<%= f.date_select :created_at %> <p/>
  <%= submit_tag " 添 加   ", :disable_with => "Saving..." %>
    <%= observe_field 'productuser_product_id',:url =>{:action =>'find_product'},:method =>'post',:update => 'product_info',
      :frequency => 0.25,:with =>'productuser[product_id]' %> 
  
<% end -%>

<table border="0" cellspacing="5" cellpadding="5" id="user_show_projects_list">
<thead>
  <tr><th>产品</th>
  <th>单价</th>
  <th>数量</th>
  <th>总计</th>
  <th>领取时间</th></tr>
</thead>
  
  <% for pu in @productusers %>
      <tr><td><%= pu.product.cn_name %>        </td>
            <td><%= pu.per_cost %>        </td>
            <td><%= pu.amount %>          </td>
            <td><%= pu.total_cost %>    </td>
            <td><%= pu.created_at.strftime("%Y-%m-%d ") %>    </td>
      </tr>
  <% end %>
  
</table> 

